<template>
  <div>
    <div class="fenlei">
      <van-nav-bar title="分类" left-arrow @click-left="onClickXiangqing" />
    </div>
    <van-grid :column-num="3" class="fen">
      <van-grid-item
        v-for="(item, index) in list"
        :key="index"
        :icon="item.pic"
        :text="item.name"
      />
      <div class="fenlei_box" v-show="!show">
          <van-empty description="没有该商品" />
      </div>
    </van-grid>
  </div>
</template>

<script>
export default {
  data() {
    return {
        show:true,
      list: [],
      id:this.$route.query.id
    };
  },
  methods: {
    onClickXiangqing() {
      this.$router.go(-1);
      this.$router.push("/Recommend_list");
    },
  },
  mounted() {
    this.$API.getStoreList().then((res) => {
      console.log(res);
      this.list = res.data.data;
      this.list = this.list.filter((item) => {
        if (item.categoryId == this.$route.query.id) {
          return item;
        }
        
      });
      if(this.list.length==0){
          this.show=false
      }else{
          this.show=true
      }

    });
   
  },
};
</script>

<style lang="scss">
* {
  padding: 0;
  margin: 0;
}
.fenlei {
  width: 100%;
  position: fixed;
  top: 0px;
  left: 0px;
  z-index: 1000;
}
.fen {
  margin-top: 0.8rem;
}
.fenlei_box{
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
</style>